package com.demo.json;

import java.util.List;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.demo.util.JacksonJsonUtils;

@MappedTypes({List.class})
@MappedJdbcTypes({JdbcType.VARCHAR, JdbcType.LONGVARCHAR, JdbcType.OTHER, JdbcType.BLOB})
public class JsonLongListHandler extends AbstractJsonTypeHandler<List<Long>> {

    public JsonLongListHandler() {}

    @Override
    protected List<Long> parse(String json) {

        return JacksonJsonUtils.readList(json, Long.class);

    }

    @Override
    protected String toJson(List<Long> obj) {
        return JacksonJsonUtils.writeObject(obj);
    }

}
